<template>
  <div class="idLogin">
    <button class="textBtn" @click="gotoTextModle">返回首页</button>
    <div class="title">
      <div>{{ $globalData.titleName }}</div>
      <div>起重机指挥实操考试自动评判系统</div>
    </div>
    <div class="idText">
      <el-input v-model="input" placeholder="请输入身份证号"></el-input>
      <button @click="validateID">点击验证</button>
    </div>
    <button class="btn" @click="clickHandle">
      <div>
        <div>人脸识别登录</div>
      </div>
    </button>
    <div v-if="isShowFlag" class="dirlog_content">
      <div class="dirlog_title">考生信息确认</div>
      <div class="dirlog_tips">
        请仔细核对考试信息，如有错误请告知监考老师！
      </div>
      <div class="dirlog_info">
        <img
          :src="'data:image/jpeg;base64,' + textStudentInfo.signInImage"
          alt=""
        />
        <div class="info">
          <div>准考证号：{{ textStudentInfo.examRegistrationNumber }}</div>
          <div>考生姓名：{{ textStudentInfo.name }}</div>
          <div>
            考生性别：{{
              textStudentInfo.idCard
                ? parseInt(textStudentInfo.idCard.slice(-2, -1)) % 2 === 1
                  ? "男"
                  : "女"
                : "未知"
            }}
          </div>
          <div>证件号码：{{ textStudentInfo.idCard }}</div>
          <div>考试项目：{{ textStudentInfo.projectWork }}</div>
          <div>项目代号：{{ textStudentInfo.projectCode }}</div>
          <div>考试时间：{{ textStudentInfo.examDate }}</div>
          <div>考试地点：{{ textStudentInfo.workUnit }}</div>
        </div>
      </div>
      <div class="dirlog_btn">
        <button class="btn1" @click="againHandleInfo">确认信息</button>
        <button class="btn2" @click="aginHandle">重新认证</button>
      </div>
    </div>
  </div>
</template>

<script>
import $api from "../untils/api.js";
import screenfull from "screenfull";
export default {
  name: "idLogin",
  data() {
    return {
      input: "",
      // input: "111111111111111111",
      isShowFlag: false,
      textStudentInfo: "",
      types: localStorage.getItem("textType"),
    };
  },
  created() {},
  methods: {
    validateID() {
      $api.checkExamineeByIdCard(this.input, this.types).then((res) => {
        if (res.data.code === 200) {
          this.$message.success("身份证号验证成功");
          this.isShowFlag = true;
          this.textStudentInfo = res.data.data;
          localStorage.setItem("id", this.textStudentInfo.id);
        } else if (res.data.code === 500) {
          this.$message.error(res.data.msg);
        }
      });
    },
    clickHandle() {
      this.$router.push({
        name: "Login",
      });
    },
    gotoTextModle() {
      this.$router.push({
        name: "home",
      });
    },
    againHandleInfo() {
      if (this.types == 1) {
        $api.startTrain(this.textStudentInfo.id).then((res) => {
          if (res.data.code == "200") {
          }
        });
      }
      if (screenfull.isEnabled) {
        screenfull.request();
        this.$store.commit("saveStudentinfo", this.textStudentInfo);
        if (this.types == 0) {
          this.$router.push({
            name: "textPage",
            params: {
              examineeId: this.textStudentInfo.id,
            },
          });
        } else if (this.types == 1) {
          this.$router.push({
            name: "textModel",
            params: {
              examineeId: this.textStudentInfo.id,
            },
          });
        }
      }
    },
    aginHandle() {
      this.isShowFlag = false;
      this.input = "";
    },
  },
};
</script>

<style  scoped>
@import url(../style/idLogin.scss);
</style>
